﻿using System;
using System.Collections.Generic;
using Sandy.Queries;

namespace Sandy.Selectors
{
    // Path: client.Family("name")["key"]
    public class ColumnGetSelector
    {
        private readonly SandyClient _client;
        private readonly SandyFamily _family;
        private readonly string _key;

        internal ColumnGetSelector(SandyClient client, SandyFamily family, string key)
        {
            _client = client;
            _family = family;
            _key = key;
        }

        public IDictionary<string, string> AllColumns
        {
            get
            {
                return this[new Range(count: int.MaxValue)];
            }
        }

        public string this[string column]
        {
            get
            {
                // throw new NotImplementedException("request 1: get(cf={0}, key={1}, col={2}");
                return GetQuery.Perform(_client, _family, _key, column);
            }
        }

        public IDictionary<string, string> this[IEnumerable<string> cols]
        {
            get
            {
                // throw new NotImplementedException("request 4: get_slice(cf={0}, key={1}, cols={2})");
                return GetSliceQuery.Perform(_client, _family, _key, cols);
            }
        }

        public IDictionary<string, string> this[params string[] cols]
        {
            get
            {
                // Request 5
                return this[(IEnumerable<string>) cols];
            }
        }

        public IDictionary<string, string> this[Range columnRange]
        {
            get
            {
                // throw new NotImplementedException("request 6: get_slice(cf={0}, key={1}, colRange={2})");
                return GetSliceQuery.Perform(_client, _family, _key, columnRange);
            }
        }
    }
}